//<!--******************************************************************************************-->
//函數名稱：GSSaddCommas
//目    的：Inserts commas into numeric string.
//參數說明：vvntValue：source string containing commas.
//回傳值：String modified with comma grouping if
//  source was all numeric, otherwise source is 
//  returned.
//備註：Used with integers or numbers with
//  2 or less decimal places.
//版本變更：
//xx. YYYY/MM/DD	AUTHOR		COMMENTS
// 1. 2002/06/19	Brenda		New Create
//<!--******************************************************************************************-->
function GSSaddCommas(vvntValue) {
	if(vvntValue==null){
		var objSrc=event.srcElement;
		event.cancelBubble=true;
		objSrc.value=objSrc.value;
		var strValue=objSrc.value;
	}
	else{
		var strValue=vvntValue;
	} 

	var tmpValue='';
	var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	strValue=GSSremoveCommas(strValue);
	if(strValue.indexOf('.')>-1){
		var tmpValue=strValue.substr(strValue.indexOf('.'),strValue.length-strValue.indexOf('.'));
		strValue=strValue.substr(0,strValue.indexOf('.'));
	}
	//check for match to search criteria
	while(objRegExp.test(strValue)) {
		//replace original string with first group match, 
		//a comma, then second group match
		strValue = strValue.replace(objRegExp, '$1,$2');
	 }
    
	if(vvntValue==null){
		objSrc.value=strValue.toString()+tmpValue.toString();}
	else{
		return strValue.toString()+tmpValue.toString();}
}

//<!--******************************************************************************************-->
//函數名稱：GSSremoveCommas
//目    的：Removes commas from source string.
//參數說明：vstrValue：Source string from which commas will 
//回傳值：Source string with commas removed.
//版本變更：
//xx. YYYY/MM/DD	AUTHOR		COMMENTS
// 1. 2002/06/19	Brenda		New Create
//<!--******************************************************************************************-->
function GSSremoveCommas(vstrValue) {
	var objRegExp = /,/g; //search for commas globally
	var strValue=vstrValue.replace(objRegExp,'');
	//replace all matches with empty strings
	return strValue.toString();
}